define([],function(){
    var tpl = {};

    tpl.courseLibirayTab = function(){
        var html = '';
        html += courseLibirayTab();
        return html;
    }
    tpl.modifyCourseClassifyForm = function(){
        var html = '';
        html += modifyCourseClassifyForm();
        return html;
    }
    tpl.addCourseForm = function(){
        var html = '';
        html += addCourseForm();
        return html;
    }
    tpl.contextMenu = function(){
        var html = '';
        html += contextMenu();
        return html;
    }
    tpl.courseInfo = function(){
        var html = '';
        html += courseInfo();
        return html;
    }
    tpl.foodLibirayTab = function(){
        var html = '';
        html += foodLibirayTab();
        return html;
    }
    tpl.courseNutrients = function(){
        var html = '';
        html += courseNutrients();
        return html;
    }
    tpl.addCourseNutrients = function(){
        var html = '';
        html += addCourseNutrients();
        return html;
    }
    tpl.courseFood = function(){
        var html = '';
        html += courseFood();
        return html;
    }
    tpl.addCoursePeriod = function(){
        var html = '';
        html += addCoursePeriod();
        return html;
    }
    tpl.addCoursePeriodLi = function(){
        var html = '';
        html += addCoursePeriodLi();
        return html;
    }
    tpl.courseLibirayWrap = function(){
        var html = '';
        html += courseLibirayWrap();
        return html;
    }
    tpl.foodConsumption = function(){
        var html = '';
        html += foodConsumption();
        return html;
    }

    var courseLibirayTab = function(){
        return  '<script id="editCourseLibiray_courseLibirayTab" type="text/html">'+
                '   <select>'+
                '       {{each list as value i}}'+
                '           <option value="{{value.libraryId}}" {{if value.libraryId == libraryId}}selected{{/if}}>{{value.libraryName}}</option>'+
                '       {{/each}}'+
                '   </select>'+
                '</script>'
    };
    var modifyCourseClassifyForm = function(){
        return  '<script id="editCourseLibiray_modifyCourseClassifyForm" type="text/html">'+
                '   <form class="form-horizontal">'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label"><i class="not-null">*</i>名称</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="text" name="name" class="form-control" value="{{name}}" placeholder="请输入名称">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">备注</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="text" name="remark" class="form-control" placeholder="请输入备注">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <div class="col-sm-offset-3 col-sm-8">'+
                '               <div id="modifyCourseClassifyBtn" class="btn btn-info">添加</div>'+
                '           </div>'+
                '       </div>'+
                '   </form>'+
                '</script>';
    };
    var addCourseForm = function(){
        return  '<script id="editCourseLibiray_addCourseForm" type="text/html">'+
                '   <form class="form-horizontal">'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label"><i class="not-null">*</i>疗程名称</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="text" name="name" class="form-control" value="{{courseName}}" placeholder="请输入疗程名称">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label"><i class="not-null">*</i>疗程天数</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="number" name="days" class="form-control" value="{{courseTotal}}" min="0">'+
                '           </div>'+
                '       </div>'+
                '       {{if !courseName}}'+ // 添加疗程
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">疗程说明</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="text" name="desc" class="form-control" placeholder="请输入疗程说明">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">备注</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="text" name="remark" class="form-control" placeholder="请输入备注">'+
                '           </div>'+
                '       </div>'+
                '       {{/if}}'+
                '       <div class="form-group">'+
                '           <div class="col-sm-offset-3 col-sm-8">'+
                '               <div id="addCourseBtn" class="btn btn-info" courseId="{{courseId}}">添加</div>'+
                '           </div>'+
                '       </div>'+
                '   </form>'+
                '</script>';
    };
    var contextMenu = function(){
        return  '<script id="editCourseLibiray_contextMenu" type="text/html">'+
                '   <ul class="dropdown-menu" role="menu">'+
                '       {{if flag == "courseClassify"}}'+
                '       <li class="rename">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>重命名</a>'+
                '       </li>'+
                '       <li class="addSubClassify">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-list" aria-hidden="true"></i>添加子分类</a>'+
                '       </li>'+
                '       <li class="addCourse">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-files-o" aria-hidden="true"></i>添加疗程</a>'+
                '       </li>'+
                '       <li class="addRootClassify">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-th-large" aria-hidden="true"></i>添加根分类</a>'+
                '       </li>'+
                '       <li class="remove">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-trash" aria-hidden="true"></i>删除</a>'+
                '       </li>'+
                '       {{/if}}'+
                '       {{if flag == "course"}}'+
                '       <li class="rename">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-pencil-square-o" aria-hidden="true"></i>重命名</a>'+
                '       </li>'+
                '       <li class="remove">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-trash" aria-hidden="true"></i>删除</a>'+
                '       </li>'+
                '       <li class="copy">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-files-o" aria-hidden="true"></i>拷贝</a>'+
                '       </li>'+
                '       {{/if}}'+
                '       {{if flag == "blank"}}'+
                '       <li class="addCourse">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-files-o" aria-hidden="true"></i>添加疗程</a>'+
                '       </li>'+
                '       <li class="addRootClassify">'+
                '           <a tabindex="-1" href="javascript:void(0);"><i class="fa fa-th-large" aria-hidden="true"></i>添加根分类</a>'+
                '       </li>'+
                '       {{/if}}'+
                '   </ul>'+
                '</script>';
    }
    var courseInfo = function(){
        return  '<script id="editCourseLibiray_courseInfo" type="text/html">'+
                '   <span>当前疗程名称：{{data.courseName}}</span>'+
                '   <span>当前疗程默认应用天数：{{data.courseTotal}}</span>'+
                '</script>';
    };
    var foodLibirayTab = function(){
        return  '<script id="editCourseLibiray_foodLibirayTab" type="text/html">'+
                '   <select>'+
                '       {{each list as value i}}'+
                '           <option value="{{value.foodLibraryId}}">{{value.foodLibraryName}}</option>'+
                '       {{/each}}'+
                '   </select>'+
                '</script>';
    };
    var courseNutrients = function(){
        return  '<script id="editCourseLibiray_courseNutrients" type="text/html">'+
                '    <table class="table table-bordered table-condensed">'+
                '        <tr>'+
                '            <th>项目</th>'+
                '            {{each list as value i}}'+
                '            <th class="course-nutrients cursor-point" courseNutrientId={{value.courseNutrientId}} courseVersionId="{{value.courseVersionId}}">'+
                '                {{value.nutrientsName}}({{value.nutrientsUnit}})'+
                '                <i class="fa fa-minus-circle" aria-hidden="true"></i>'+
                '            </th>'+
                '            {{/each}}'+
                '            <th class="cursor-point" id="addCourseNutrients">'+
                '                添加新指标'+
                '                <i class="fa fa-plus-circle" aria-hidden="true"></i>'+
                '            </th>'+
                '        </tr>'+
                '        <tr>'+
                '            <td>推荐剂量</td>'+
                '            {{each list as value i}}'+
                '            <td class="dblclick-edit" name="averageAmount" courseNutrientId="{{value.courseNutrientId}}" courseVersionId="{{value.courseVersionId}}" nutrientsId="{{value.nutrientsId}}">{{value.averageAmount}}</td>'+
                '            {{/each}}'+
                '            <td></td>'+
                '        </tr>'+
                '        <tr>'+
                '            <td>摄入下限</td>'+
                '            {{each list as value i}}'+
                '            <td class="dblclick-edit" name="minAmount" courseNutrientId="{{value.courseNutrientId}}" courseVersionId="{{value.courseVersionId}}" nutrientsId="{{value.nutrientsId}}">{{value.minAmount}}</td>'+
                '            {{/each}}'+
                '            <td></td>'+
                '        </tr>'+
                '        <tr>'+
                '            <td>摄入上限</td>'+
                '            {{each list as value i}}'+
                '            <td class="dblclick-edit" name="maxAmount" courseNutrientId="{{value.courseNutrientId}}" courseVersionId="{{value.courseVersionId}}" nutrientsId="{{value.nutrientsId}}">{{value.maxAmount}}</td>'+
                '            {{/each}}'+
                '            <td></td>'+
                '        </tr>'+
                '        <tr>'+
                '            <td>当前计量</td>'+
                '            {{each list as value i}}'+
                '            <td>{{value.actualAmount}}</td>'+
                '            {{/each}}'+
                '            <td></td>'+
                '        </tr>'+
                '    </table>'+
                '</script>';
    };
    var addCourseNutrients = function(){
        return  '<script id="editCourseLibiray_addCourseNutrients" type="text/html">'+
                '   <form class="form-horizontal add-course-nutrients">'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label"><i class="not-null">*</i>营养元素名称</label>'+
                '           <div class="col-sm-8">'+
                '               <select name="name" class="form-control">'+
                '                   {{each list as value i}}'+
                '                   <option nutrientsUnit="{{value.nutrientsUnit}}" value="{{value.nutrientsId}}">{{value.nutrientsName}}</option>'+
                '                   {{/each}}'+
                '               </select>'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">营养元素单位</label>'+
                '           <div class="col-sm-8">'+
                '               <p class="form-control-static" name="unit">kg</p>'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">推荐剂量</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="number" min="0" name="recommendedDose" class="form-control" placeholder="请输入推荐剂量">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">摄入下限</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="number" min="0" name="minIntake" class="form-control" placeholder="请输入摄入下限">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <label class="col-sm-3 control-label">摄入上限</label>'+
                '           <div class="col-sm-8">'+
                '               <input type="number" min="0" name="maxIntake" class="form-control" placeholder="请输入摄入上限">'+
                '           </div>'+
                '       </div>'+
                '       <div class="form-group">'+
                '           <div class="col-sm-offset-3 col-sm-8">'+
                '               <div id="addCourseNutrientsBtn" class="btn btn-info">添加</div>'+
                '           </div>'+
                '       </div>'+
                '   </form>'+
                '</script>';
    }
    var courseFood = function(){
        return  '<script id="editCourseLibiray_courseFood" type="text/html">'+
                '    <table courseVersionId="{{courseVersionId}}" class="table table-bordered table-condensed">'+
                '        <tr>'+
                '            <th id="addCoursePeriod" class="cursor-point">时段<i class="fa fa-pencil-square-o" id="edit-time" aria-hidden="true"></i></th>'+
                '            <th>食物</th>'+
                '            <th>营养成分</th>'+
                '            <th>食物单位含量</th>'+
                //'            <th>包装单位量</th>'+
                '            <th>用量</th>'+
                '        </tr>'+
                '        {{each list as value i}}'+
                '           {{each value.foodList as item j}}'+
                '           <tr>'+
                '               {{if j==0}}'+
                '                   <td rowspan="{{value.foodList.length}}">{{value.periodName}} {{value.time}}</td>'+
                '               {{/if}}'+
                '               <td class="food-name" periodId="{{value.periodId}}" periodName = "{{value.periodName}}" periodTime = "{{value.time}}" courseFoodId="{{item.courseFoodId}}" foodId="{{item.foodId}}" foodName = "{{item.foodName}}">'+
                '                   {{item.foodName}}'+
                '                   {{if item.foodName}}'+
                '                   <i class="fa fa-minus-circle del-course-food" aria-hidden="true"></i>'+
                '                   {{/if}}'+
                '               </td>'+
                '               <td>'+
                '                   {{item.nutrientNames}}'+
               /* '                   {{each item.nutrientsNames as val}}'+
                '                       {{val}},'+
                '                   {{/each}}'+*/
                '               </td>'+
                '               <td>{{item.foodContent}}{{item.foodUnit}}</td>'+
                //'               <td class="dblclick-edit" name="packageTotal"><span>{{item.packageTotal}}</span>{{item.foodPackageUnit}}</td>'+
                '               <td class="dblclick-edit" name="total">'+
                '                 {{if item.total}}'+
                '                   <span class="need-dblclick">{{item.total}}</span>'+
                '                 {{else}}'+
                '                   <span class="no-need-dblclick">' +
                '                    {{if item.foodName}}'+
                '                       <input type="number" min="0" value="{{item.total}}">' +
               /* '                    {{else}}'+
                '                       <input type="number" min="0" value="{{item.total}}">' +*/
                '                    {{/if}}'+
                '                   </span>'+
                '                 {{/if}}'+
                '                   <font class="unit">{{item.foodUnit}}</font>'+
                '               </td>'+
                '           </tr>'+
                '           {{/each}}'+
                '        {{/each}}'+
                '   </table>'+
                '</script>';
    }
    var addCoursePeriod = function(){
        return  '<script id="editCourseLibiray_addCoursePeriod" type="text/html">'+
                '    <div class="edit-period">'+
                '        <div class="text-center">'+
                '            <button id="addPeriod" class="btn btn-info">'+
                '                <i class="fa fa-plus-circle" aria-hidden="true"></i>添加时段'+
                '            </button>'+
                '        </div>'+
                '        <ul id="periodBox">'+
                '            {{each list as value i}}'+
                '            <li periodId="{{value.periodId}}">'+
                '                <div class="period-name clearfix">'+
                '                    时段名称：<input type="text" value="{{value.periodName}}">'+
                '                    <i class="delPeriod pull-right fa fa-trash-o" aria-hidden="true"></i>'+
                '                    <i class="savePeriod pull-right fa fa-floppy-o" aria-hidden="true"></i>'+
                '                </div>'+
                '                <div class="period-time">'+
                '                    <select class="form-control startTime-hours">'+
                '                        {{each hours as value1 i}}'+
                '                           <option value="{{value1}}" {{if value1==value.startTimeHours}}selected{{/if}}>{{value1}}</option>'+
                '                        {{/each}}'+
                '                    </select>'+
                '                    :'+
                '                    <select class="form-control startTime-min">'+
                '                        {{each min as value1 i}}'+
                '                           <option value="{{value1}}" {{if value1==value.startTimeMin}}selected{{/if}}>{{value1}}</option>'+
                '                        {{/each}}'+
                '                    </select>'+
                '                    ~'+
                '                    <select class="form-control endTime-hours">'+
                '                        {{each hours as value1 i}}'+
                '                           <option value="{{value1}}" {{if value1==value.endTimeHours}}selected{{/if}}>{{value1}}</option>'+
                '                        {{/each}}'+
                '                    </select>'+
                '                    :'+
                '                    <select class="form-control endTime-min">'+
                '                        {{each min as value1 i}}'+
                '                           <option value="{{value1}}" {{if value1==value.endTimeMin}}selected{{/if}}>{{value1}}</option>'+
                '                        {{/each}}'+
                '                    </select>'+
                '                </div>'+
                '            </li>'+
                '            {{/each}}'+
                '        </ul>'+
                '    </div>'+
                '</script>';
    }
    var addCoursePeriodLi = function(){
        return  '<script id="editCourseLibiray_addCoursePeriodLi" type="text/html">'+
                '   <li>'+
                '       <div class="period-name clearfix">'+
                '           时段名称：<input type="text" placeholder="请输入时段名称">'+
                '           <i class="delPeriod pull-right fa fa-trash-o" aria-hidden="true"></i>'+
                '           <i class="savePeriod pull-right fa fa-floppy-o" aria-hidden="true"></i>'+
                '       </div>'+
                '       <div class="period-time">'+
                '           <select class="form-control startTime-hours">'+
                '               {{each hours as value i}}'+
                '                  <option value="{{value}}">{{value}}</option>'+
                '               {{/each}}'+
                '           </select>'+
                '           :'+
                '           <select class="form-control startTime-min">'+
                '               {{each min as value i}}'+
                '                  <option value="{{value}}">{{value}}</option>'+
                '               {{/each}}'+
                '           </select>'+
                '           ~'+
                '           <select class="form-control endTime-hours">'+
                '               {{each hours as value i}}'+
                '                  <option value="{{value}}">{{value}}</option>'+
                '               {{/each}}'+
                '           </select>'+
                '           :'+
                '           <select class="form-control endTime-min">'+
                '               {{each min as value i}}'+
                '                  <option value="{{value}}">{{value}}</option>'+
                '               {{/each}}'+
                '           </select>'+
                '       </div>'+
                '   </li>';
                '</script>';
    }
    var courseLibirayWrap = function(){
        return  '<script id="editCourseLibiray_courseLibirayWrap" type="text/html">'+
                '   {{if list.length > 0}}'+
                '       <ul class="ztree" id="ztreeCourseLibiray"></ul>'+
                '   {{else}}'+
                '       <div class="tip-null">右击该空白处可添加疗程以及疗程分类！</div>'+
                '   {{/if}}'+
                '</script>';
    }
    var foodConsumption = function(){
        return 	'<script id="course_foodConsumption" type="text-html">'+
            '	<form class="form-horizontal" >'+
            '	    <div class="form-group" style="margin-bottom:0;">'+
            '	      	<label class="col-sm-4 control-label text-right">时段</label>'+
            '    		<div class="col-sm-5" style="line-height:30px;">{{periodName}}</div>'+
            '	    </div>'+
            '	    <div class="form-group" style="margin-bottom:0;">'+
            '	      	<label class="col-sm-4 control-label text-right">食物名称</label>'+
            '    		<div class="col-sm-5" style="line-height:30px;">{{title}}</div>'+
            '	    </div>'+
            '	    <div class="form-group" style="margin-bottom:5px;">'+
            '	      	<label for="foodConsumption" class="col-sm-4 control-label text-right">用量</label>'+
            '    		<div class="col-sm-5">'+
            '               <input type="number" id="foodConsumption" class="form-control foodConsumption" placeholder="请输入食物用量" min=0 value="{{value}}">{{unit}}'+
            '    		</div>'+
            '	    </div>'+
            '	    <div class="form-group" style="margin-bottom:5px;">'+
            '	      	<label class="col-sm-4"></label>'+
            '    		<div class="col-sm-4 text-left">'+
            '      			<div id="sureFoodConsumption" class="btn btn-primary">确认</div>'+
            '      			{{if value}}<div class="btn btn-default" data-dismiss="modal">取消</div>{{/if}}'+
            '    		</div>'+
            '	    </div>'+
            '	</form>'+
            '</script>';
    }
    return tpl;
});